<template>
	<view>
		<u-navbar back-text=" " :title="title" :background="background" title-color="#539031"
			back-icon-color="#539031"></u-navbar>
		<u-swiper :effect3d="false" :title="false" :height="350" :list="vuex_config.swiper_ptkc" v-if="swiper_ptkc==1"></u-swiper>
		<u-swiper :effect3d="false" :title="false" :height="350" :list="vuex_config.swiper_ptts" v-if="swiper_ptts==1"></u-swiper>
		<u-swiper :effect3d="false" :title="false" :height="350" :list="vuex_config.swiper_school" v-if="swiper_school==1"></u-swiper>
		
		<view class="" v-if="list.length">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#539031"></u-tabs>
		</view>
		<image :src="infoData[current].image" mode="widthFix" style="width: 100%;"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: "#f6fae9",
				},
				current: 0,
				list: [],
				title: '',
				infoData: [],
				type: "",
				swiper_ptkc:0,
				swiper_ptts:0,
				swiper_school:0
				
			}
		},
		onLoad(option) {
			console.log(option)
			if (option.type == 1) {
				this.title = '破土课程';
				this.swiper_ptkc=1;
			}
			if (option.type == 2) {
				this.title = '破土图书馆',
				this.swiper_ptts=1;
				
			}
			if (option.type == 3) {
				this.title = '乡村小学'
				this.swiper_school=1;
			}
			this.type = option.type
			this.getInfo()
		},
		methods: {
			change(index) {
				this.current = index;
			},
			getInfo() {
				this.list = []
				if (this.type == 1) {
					//破土课程
					this.$api.getPtkclist().then(({
						code,
						data: res,
						msg
					}) => {
						if (code) {
							console.log(1112222, res);
							if (res.data.length) {
								res.data.forEach(e => {
									this.list.push({
										name: e.year,
										e,
									})
								})
							}
							this.infoData = res.data
						}
					});
				} else if (this.type == 2) {
					//破土图书馆
					this.$api.getPttsjlist().then(({
						code,
						data: res,
						msg
					}) => {
						if (code) {
							console.log(111, res);
							if (res.data.length) {
								res.data.forEach(e => {
									this.list.push({
										name: e.year,
										e,
									})
								})
							}
							this.infoData = res.data
						}
					});
				} else if (this.type == 3) {
					//乡村小学
					this.$api.getSchoollist().then(({
						code,
						data: res,
						msg
					}) => {
						if (code) {
							console.log(111, res);
							if (res.data.length) {
								res.data.forEach(e => {
									this.list.push({
										name: e.year,
										e,
									})
								})
							}
							this.infoData = res.data
						}
					});
				}

			},
		}
	}
</script>

<style>

</style>